<template>
    <div class="data-content">
        <el-table :data="itemList" border style="width: 100%">
            <el-table-column fixed label="序号" width="50">
                <template slot-scope="scope">
                    <span>{{ (page - 1) * pageSize + scope.$index + 1 }}</span>
                </template>
            </el-table-column>
            <el-table-column label="发布日期" width="200">
                <template slot-scope="scope">
                    {{ parseInt(scope.row.publishTime) |formatDate}}
                </template>
            </el-table-column>
            <el-table-column prop="title" label="标题" width="100" :show-overflow-tooltip="true">
            </el-table-column>
            <el-table-column prop="purchaser"  min-width="150" label="采购人">
            </el-table-column>
        </el-table>
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :page-sizes="[10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next"
            style="text-align:right; margin-top:1em;"
            :total="total">
        </el-pagination>
    </div>
</template>

<script>
import { formatDate } from "../../js/common";

export default {
    props: {
        companyName: {
            type: String,
            default: "",
        },
        projectId: {
            type: String,
            default: "",
        },
    },
    data: () => ({
        size: 1,
        page: 1,
        pageSize: 10,
        itemList: [],
        total: null
    }),
    methods: {
        handleSizeChange: function (size) {
            this.pageSize = size;
            this.getList()
        },
        handleCurrentChange: function(page){
            this.page = page;
            this.getList()
        },
        currentPage:function (){
            this.getList()
        },
        //获取企业基本信息
        getList() {
            var that = this;
            this.$ajax({
                type: "get",
                url: `${that.$store.state.api.searchUrl}/searchtianyan/getZhaoTouBiao`,
                data: {
                    corpName: that.companyName,
                    projectId: that.projectId,
                    pageNum: this.page,
                    pageSize: this.pageSize,
                },
                callback: function (data, res) {
                    if(data.result) {
                        that.itemList = data.result.items;
                        that.total = data.result.total;
                    }
                },
            });
        },
    },
    filters: {
        formatDate (time) {
            let date = new Date(time)
            return formatDate (date, 'yyyy-MM-dd')
        }
    },
    mounted() {
        this.getList();
    },
};
</script>

<style scoped lang="scss">
.data-content {
    // border-bottom: 1px solid #efefef;
    padding: 10px 0px;
}
</style>
